package com.cn.JUC.pattern.case21;

import lombok.extern.slf4j.Slf4j;

/**
 * @Title 中断线程
 * @Description TODO
 * @Author CAI ZHAI
 * @Date 2021/9/14 16:43
 **/
@Slf4j
public class Interrupted{
    public static void main(String[] args){
        Thread1 thread1 = new Thread1();
        Thread thread = new Thread(new Thread1());
        thread.start();
    
        try{
            Thread.sleep(5000);
    
            thread.interrupt();//实质上，这个方法仅仅是设置一个变量，interrupt=true，与线程状态无关。
        }catch(InterruptedException e){
            e.printStackTrace();
        }
    
    
    }
    
    
}
